package cn.caipengbo.validatecode;

import cn.dsna.util.images.ValidateCode;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Myth on 1/21/2017.
 */
@WebServlet(name = "CreateValidateCode")
public class CreateValidateCode extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //生成验证码
        ValidateCode code = new ValidateCode(100,50,4,50);
        //放入session
        request.getSession().setAttribute("code",code.getCode());
        //将图片返给浏览器
        code.write( response.getOutputStream());

    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }


}
